package se.webbzon.boltzmann.game;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import se.webbzon.boltzmann.player.PlayerConfiguration;

public class GameConfiguration {
	
	// The players to load into the game
	private final List<PlayerConfiguration> players;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new game configuration structure which can
	 * be used to load games. **/
	public GameConfiguration() {
		this(null);
	}
	
	/** Creates a new game configuration structure which can
	 * be used to load games. **/
	public GameConfiguration(PlayerConfiguration[] players) {
		if (players == null)
			this.players = new ArrayList<PlayerConfiguration>();
		else
			this.players = Arrays.asList(players);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the number of player configurations that should be loaded
	 * into the game. **/
	public int players() {
		return players.size();
	}
	
	/** Returns the (n+1):th player configuration that should be loaded 
	 * into the game. **/
	public PlayerConfiguration getPlayer(int n) {
		return players.get(n);
	}
	
	/** Adds a player configuration to this game configuration. **/
	public boolean addPlayer(PlayerConfiguration player) {
		return players.add(player);
	}
	
	/** Removes a player configuration from this game configuration. **/
	public boolean removePlayer(PlayerConfiguration player) {
		return players.remove(player);
	}
	
	/** Removes all the player configurations from this game configuration. **/
	public void clearPlayers() {
		players.clear();
	}

}
